<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Golang,Revel," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="毕业设计为了给自己点压力就提交了一个用go语言做的题目，然后很顺利的通过了。导师很欣慰的跟我说：“孩子你真不错，好好做，努力加油。”之后每想起这件事就哭得跟个泪人儿似的。
这个项目答辩后会开源在我的Github上，如果有兴趣的同学大家可以拿来练练手。">
<meta property="og:type" content="article">
<meta property="og:title" content="Go语言Web框架Revel初体验">
<meta property="og:url" content="/2017/02/04/Go语言Web框架Revel的使用/index.html">
<meta property="og:site_name" content="Porson's Bolg">
<meta property="og:description" content="毕业设计为了给自己点压力就提交了一个用go语言做的题目，然后很顺利的通过了。导师很欣慰的跟我说：“孩子你真不错，好好做，努力加油。”之后每想起这件事就哭得跟个泪人儿似的。
这个项目答辩后会开源在我的Github上，如果有兴趣的同学大家可以拿来练练手。">
<meta property="og:updated_time" content="2017-02-23T03:31:11.750Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Go语言Web框架Revel初体验">
<meta name="twitter:description" content="毕业设计为了给自己点压力就提交了一个用go语言做的题目，然后很顺利的通过了。导师很欣慰的跟我说：“孩子你真不错，好好做，努力加油。”之后每想起这件事就哭得跟个泪人儿似的。
这个项目答辩后会开源在我的Github上，如果有兴趣的同学大家可以拿来练练手。">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"right","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 'porson',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="/2017/02/04/Go语言Web框架Revel的使用/"/>





  <title> Go语言Web框架Revel初体验 | Porson's Bolg </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="/images/favicon.png"
             alt="Porson's Bolg"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Porson's Bolg</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
    
      <p class="site-subtitle">MySQL/Python/Golang/Others</p>
    
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user-md"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="/2017/02/04/Go语言Web框架Revel的使用/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Porson">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Porson's Bolg">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Porson's Bolg" src="/images/favicon.png">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Go语言Web框架Revel初体验
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-02-04T17:01:30+08:00">
                2017-02-04
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/02/04/Go语言Web框架Revel的使用/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/02/04/Go语言Web框架Revel的使用/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>毕业设计为了给自己点压力就提交了一个用go语言做的题目，然后很顺利的通过了。导师很欣慰的跟我说：“孩子你真不错，好好做，努力加油。”之后每想起这件事就哭得跟个泪人儿似的。</p>
<p>这个项目答辩后会开源在我的Github上，如果有兴趣的同学大家可以拿来练练手。</p>
<a id="more"></a>
<h3 id="什么是Revel"><a href="#什么是Revel" class="headerlink" title="什么是Revel"></a>什么是Revel</h3><p>Revel官网给予的说明是：一个高生产力的 Go 语言 Web 框架。</p>
<p>根据Web Framework Benchmarks测评显示，Revel目前性能排名第八的Web框架。注意，是<strong>全语言全框架</strong>性能排名第八。</p>
<p><a href="http://www.techempower.com/benchmarks/#section=data-r8" target="_blank" rel="external">查看测试报告</a></p>
<h3 id="Revel特性"><a href="#Revel特性" class="headerlink" title="Revel特性"></a>Revel特性</h3><h4 id="热编译"><a href="#热编译" class="headerlink" title="热编译"></a>热编译</h4><p>现在不能热编译的框架还叫框架？</p>
<blockquote>
<p>编辑, 保存, 和 刷新时，Revel自动编译代码和模板，如果代码编译错误，会给出一个 <a href="http://www.gorevel.cn/docs/img/CompilationError.png" target="_blank" rel="external">错误提示</a>，同时捕捉 <a href="http://www.gorevel.cn/docs/img/Panic.png" target="_blank" rel="external">运行期错误</a>。</p>
</blockquote>
<h4 id="全栈功能"><a href="#全栈功能" class="headerlink" title="全栈功能"></a>全栈功能</h4><p><del>特别适合我这种全栈工程师</del></p>
<blockquote>
<p>Revel 支持： <a href="http://www.gorevel.cn/docs/manual/routing.html" target="_blank" rel="external">路由</a>, <a href="http://www.gorevel.cn/docs/manual/binding.html" target="_blank" rel="external">参数解析</a>, <a href="http://www.gorevel.cn/docs/manual/validation.html" target="_blank" rel="external">验证</a>,<a href="http://www.gorevel.cn/docs/manual/sessionflash.html" target="_blank" rel="external">session/flash</a>, <a href="http://www.gorevel.cn/docs/manual/templates.html" target="_blank" rel="external">模板</a>, <a href="http://www.gorevel.cn/docs/manual/cache.html" target="_blank" rel="external">缓存</a>, <a href="http://www.gorevel.cn/docs/manual/jobs.html" target="_blank" rel="external">计划任务</a>, <a href="http://www.gorevel.cn/docs/manual/testing.html" target="_blank" rel="external">测试</a>, <a href="http://www.gorevel.cn/docs/manual/i18n-messages.html" target="_blank" rel="external">国际化</a> 等功能。</p>
</blockquote>
<h4 id="框架设计"><a href="#框架设计" class="headerlink" title="框架设计"></a>框架设计</h4><p>Revel秉持模块化无状态的同步设计，所以拓展性高，灵活性强。</p>
<p>熟悉Python的同学肯定使用过Django，就我目前的开发感觉来看，转过来用的非常舒服，理解起来没有障碍。</p>
<hr>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><p>说了这么多，到底怎么样使用呢？</p>
<p>Go与其他语言不同，Go语言本身就集成了相当多的工具，所以无论是第三方包的下载还是安装，都是非常灵活方便的。<del>除了需要翻墙</del></p>
<h4 id="一、科学上网"><a href="#一、科学上网" class="headerlink" title="一、科学上网"></a>一、科学上网</h4><p>是的，这是第一步，没有这一步你连包都下不全，有一部分的代码在google的服务器上。</p>
<p>但是你要是说就是不想翻墙，或者就是不会怎么办？</p>
<h4 id="二、第三方包下载工具"><a href="#二、第三方包下载工具" class="headerlink" title="二、第三方包下载工具"></a>二、第三方包下载工具</h4><p><a href="http://www.golangtc.com/download/package" target="_blank" rel="external">Golang中国第三方包下载工具</a></p>
<p>上面的说明写的十分详细简单，我也就不赘述了。</p>
<h4 id="三、开始安装"><a href="#三、开始安装" class="headerlink" title="三、开始安装"></a>三、开始安装</h4><p>安装Revel需要安装两个包</p>
<ol>
<li>github.com/revel/revel</li>
<li>github.com/revel/cmd/revel</li>
</ol>
<p>第一个是Revel本体，第二个是命令行工具。</p>
<p>不过这两个包只有第一个需要翻墙。</p>
<hr>
<p>在第三方包下载工具当中输入包名</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">github.com/revel/revel</div></pre></td></tr></table></figure>
<p>然后等工具下载完后下载到本地，解压所有文件到你的GOPATH路径下的src目录下。</p>
<p>然后在命令行中输入</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">go install github.com/revel/revel</div></pre></td></tr></table></figure>
<p>等待成功后就可以安装命令行工具</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">go get github.com/revel/cmd/revel</div></pre></td></tr></table></figure>
<h3 id="完成"><a href="#完成" class="headerlink" title="完成"></a>完成</h3><p>接下来就是按照官网上的指示创建Revel应用即可。</p>
<p>非常简单，初学者可能会卡在科学上网上。</p>
<p><a href="http://www.gorevel.cn/" target="_blank" rel="external">Revel中文站</a></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Golang/" rel="tag"># Golang</a>
          
            <a href="/tags/Revel/" rel="tag"># Revel</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/02/04/文件编码自动转换模块的实现/" rel="next" title="Python文件编码自动转换模块的实现">
                <i class="fa fa-chevron-left"></i> Python文件编码自动转换模块的实现
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/02/04/解决Python在Windows环境运行时的编码问题/" rel="prev" title="解决Python在Windows环境运行时的编码问题">
                解决Python在Windows环境运行时的编码问题 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2017/02/04/Go语言Web框架Revel的使用/"
           data-title="Go语言Web框架Revel初体验" data-url="/2017/02/04/Go语言Web框架Revel的使用/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="Porson" />
          <p class="site-author-name" itemprop="name">Porson</p>
          <p class="site-description motion-element" itemprop="description">DBA/Python程序员/开源爱好者</p>
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/porson" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#什么是Revel"><span class="nav-number">1.</span> <span class="nav-text">什么是Revel</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Revel特性"><span class="nav-number">2.</span> <span class="nav-text">Revel特性</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#热编译"><span class="nav-number">2.1.</span> <span class="nav-text">热编译</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#全栈功能"><span class="nav-number">2.2.</span> <span class="nav-text">全栈功能</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#框架设计"><span class="nav-number">2.3.</span> <span class="nav-text">框架设计</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装"><span class="nav-number">3.</span> <span class="nav-text">安装</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#一、科学上网"><span class="nav-number">3.1.</span> <span class="nav-text">一、科学上网</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#二、第三方包下载工具"><span class="nav-number">3.2.</span> <span class="nav-text">二、第三方包下载工具</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#三、开始安装"><span class="nav-number">3.3.</span> <span class="nav-text">三、开始安装</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#完成"><span class="nav-number">4.</span> <span class="nav-text">完成</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  <span class="author" itemprop="copyrightHolder">Create by Porson </span>
    <span class="with-love">
    <i class="fa fa-copyright"></i>
  </span>
   2016 - 
  <span itemprop="copyrightYear">2017</span>
  All copyright

</div>



        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"lpx"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  












  
  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

  


</body>
</html>
